package org.monster.context.core.response;

import org.monster.context.core.parameter.HttpResponse;
import org.monster.context.core.processor.Process;
import org.monster.context.core.request.HttpRequest;

/**
 * 响应上下文
 *
 * @author Monster
 */
public class ResponseContext {

    /**
     * 响应状态
     */
    private final ResponseState responseState = new ResponseState();

    /**
     * 响应
     *
     * @param request  请求
     * @param response 响应
     * @throws ClassNotFoundException 类未找到异常
     */
    public void response(HttpRequest request, HttpResponse response) throws ClassNotFoundException {
        String state = ResponseFactory.getState(request, response);
        Process process = ResponseFactory.getInstance(state);
        boolean isProcessed = process.process(request, response);
        if (!isProcessed) {
            process = ResponseFactory.getInstance(ResponseState.CLASS_RESOURCE);
            process.process(request, response);
        }
    }
}
